unit uMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uFormBaseNormal, JvComponentBase, JvBalloonHint, Menus, JvMenus, ImgList,
  JvImageList, ActnList, JvVersionControlActions, ExtCtrls, JvExExtCtrls,
  JvImage, JvExControls, JvButton, JvTransparentButton, JvExtComponent, JvPanel,
  JvGradientHeaderPanel, JvLabel, JvTrayIcon, JvSystemPopup, JvBevel, ToolWin,

  uFormBase, uDodawanieMetryka, uPorzadkiPKD, uRaporty, uUprawomocnieniaWykreslen,
  uRedakcjaPodmiotow, uRedakcjaMetryk,

  ComCtrls, JvExComCtrls, JvToolBar, AppEvnts, uBaseForm, Buttons, PerlRegEx, uADStanIntf,
  uADStanOption, uADStanError, uADGUIxIntf, uADPhysIntf, uADStanDef, uADStanPool,
  uADPhysManager, uADCompClient, DB, StdCtrls, JvExStdCtrls, JvEdit, Mask, JvExMask,
  JvToolEdit, JvMaskEdit, JvCheckedMaskEdit, JvDatePickerEdit;

type
  TfMain = class(TfBaseForm)
    JvImageTlo: TJvImage;
    JvTrayIcon: TJvTrayIcon;
    JvPopupMenuTrayIcon: TJvPopupMenu;
    pmCloseApp: TMenuItem;
    tbtnAddMeryki: TJvTransparentButton;
    tbtnRedakcjaMetryki: TJvTransparentButton;
    tbtnRedakcjaPodmoty: TJvTransparentButton;
    tbtnRaporty: TJvTransparentButton;
    actAddMertyka: TAction;
    actEditMetryka: TAction;
    actEditPodmiot: TAction;
    actRaport: TAction;
    N1: TMenuItem;
    Wprowadzaniemetryk1: TMenuItem;
    Redakcjametryk1: TMenuItem;
    Redakcjapodmiotw1: TMenuItem;
    N2: TMenuItem;
    Raporty1: TMenuItem;
    N3: TMenuItem;
    Wprowadzaniemetryk2: TMenuItem;
    Redakcjametryk2: TMenuItem;
    Redakcjapodmiotw2: TMenuItem;
    Raporty2: TMenuItem;
    MenuItemAdministracja: TMenuItem;
    JvTBMain: TJvToolBar;
    actClearPKD: TAction;
    PorzdkiPKD1: TMenuItem;
    PMIRedakcja: TMenuItem;
    N4: TMenuItem;
    PMIAdministracja: TMenuItem;
    PorzdkiPKD2: TMenuItem;
    JvTransparentButton1: TJvTransparentButton;
    tbtnPorzadkiPKD: TJvTransparentButton;
    JvTransparentButton2: TJvTransparentButton;
    actUprawWykr: TAction;
    Uprawomocnienia1: TMenuItem;
    Uprawomocnienia2: TMenuItem;
    procedure FormCreate(Sender: TObject);
    procedure actMinFormExecute(Sender: TObject);
    procedure JvTrayIconDblClick(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure FormShow(Sender: TObject);
    procedure actEditMetrykaExecute(Sender: TObject);
    procedure actEditPodmiotExecute(Sender: TObject);
    procedure actRaportExecute(Sender: TObject);
    procedure actAddMertykaExecute(Sender: TObject);
    procedure actClearPKDExecute(Sender: TObject);
    procedure actUprawWykrExecute(Sender: TObject);
  private
    { Private declarations }
    fRedakcjaPodmiotow1: TfRedakcjaPodmiotow;
    fRedakcjaPodmiotow2: TfRedakcjaPodmiotow;
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
  end;

var
  fMain: TfMain;

implementation

uses
  uGlobal;

{$R *.dfm}

procedure TfMain.actAddMertykaExecute(Sender: TObject);
begin
  inherited;
  try
//    if not Assigned(fDodawanieMetryka) then
//      fDodawanieMetryka := TfDodawanieMetryka.Create(Application);
    ShowForm(TfDodawanieMetryka.Create(Application));
  except
    raise;
  end;
end;

procedure TfMain.actClearPKDExecute(Sender: TObject);
begin
  inherited;
  try
//    if not Assigned(fPorzadkiPKD) then
//      fPorzadkiPKD := TfPorzadkiPKD.Create(Application);
    ShowForm(TfPorzadkiPKD.Create(Application));
  except
    raise;
  end;
end;

procedure TfMain.actEditMetrykaExecute(Sender: TObject);
begin
  inherited;
  try
    ShowForm(TfRedakcjaMetryk.Create(Application));
  except
    raise;
  end;
end;

procedure TfMain.actEditPodmiotExecute(Sender: TObject);
begin
  inherited;
  try
    ShowForm(TfRedakcjaPodmiotow.Create(Application));
  except
    raise;
  end;
end;

procedure TfMain.actMinFormExecute(Sender: TObject);
begin
  //inherited;
  Self.JvTrayIcon.HideApplication;
end;

procedure TfMain.actRaportExecute(Sender: TObject);
begin
  inherited;
  try
    ShowForm(TfRaporty.Create(Application));
  except
    raise;
  end;
end;

procedure TfMain.actUprawWykrExecute(Sender: TObject);
begin
  inherited;
  try
    ShowForm(TfUprawomocnieniaWykreslen.Create(Application));
  except
    raise;
  end;
end;

constructor TfMain.Create(AOwner: TComponent);
begin
  inherited MyCreate(AOwner, MyBsNoneRisize);
end;

procedure TfMain.FormCreate(Sender: TObject);
begin
  inherited;
//  if not Self.JvImageIcon.Picture.Icon.Empty then
  JvTrayIcon.Icon := Application.Icon;
    //Self.JvImageIcon.Picture.Icon;
  //ustala wielkosc okan main
  //Self.Height := 330;
  //Self.Width := 315;
  PODMIOTY_DATA_WPISU := GetStrValueIniFile(SETTINGS_SECTION_NAME, SETTINGS_DATA_WPISU);
  PODMIOTY_KATALOG_PDF := GetStrValueIniFile(SETTINGS_SECTION_NAME, SETTINGS_KATALOG_PDF);
  REDAKCJA_METRYK_DATA_WPISU := PODMIOTY_DATA_WPISU;
  REDAKCJA_METRYK_KATALOG_PDF := PODMIOTY_KATALOG_PDF;

end;

procedure TfMain.FormShow(Sender: TObject);
begin
  inherited;
  //JvTBMain.Visible := false;
  //JvTBMain.Visible := true;;
end;

procedure TfMain.JvTrayIconDblClick(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  inherited;
  if ssShift in Shift then
    if IsWindowVisible(Handle) then
      Self.JvTrayIcon.HideApplication
    else
      Self.JvTrayIcon.ShowApplication;
end;

end.
